#include <memory.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#define LLEN 2000*1024

struct tree {
	int a;
	struct tree *left;
	struct tree *right;
};

void insert(struct tree **root, struct tree *item)
{
	if (!(*root))
	{
		*root = item;
		return;
	}
//       	printf("item = %d\n",item->a); 
	if (item->a < (*root)->a)
		insert(&(*root)->left, item);
	else
		if(item->a > (*root)-> a)
			insert(&(*root)->right,item);
}

printout(struct tree *root)
{
	if (root->left) printout(root->left);
	printf("%d\n",root->a);
	if (root->right) printout(root->right);
}


main()
{

struct tree *root, *temp;
int i;

root = NULL;
for(i=1;i<=LLEN;i++)
{
	
	temp = (struct tree *)malloc(sizeof(struct tree));
	temp->left = temp->right=NULL;
	temp->a=rand();
	insert(&root,temp);
}


printout(root);
}
